Skip to content

refactor(app): extract resetSessionScopedUiState() helper (#1394)#1398

Merged
cliffhall merged 1 commit into
v2/mainfrom
refactor/1394-reset-session-state-helper
Jun 1, 2026
Merged

refactor(app): extract resetSessionScopedUiState() helper (#1394)#1398
cliffhall merged 1 commit into
v2/mainfrom
refactor/1394-reset-session-state-helper

Conversation

@cliffhall
Copy link
Copy Markdown
Member

Closes #1394.

What

Extracts the four session-scoped UI resets that the disconnect listener in App.tsx performs — the per-call result panels (toolCallState / getPromptState / readResourceState) and the optimistic currentLogLevel — into a colocated resetSessionScopedUiState useCallback. The listener keeps its activeServerId + Connection Info modal-flag bookkeeping inline and calls the helper.

Why now

#1394 was filed as a deferred tripwire during the #1368 review: the note was to extract this helper once App.tsx accrued more per-session state, since four inline setters is below the abstraction threshold. We've opted to do it now anyway so there's a single named seam (resetSessionScopedUiState) to extend as that state grows — the next addition is one line in the helper instead of another setter buried in the listener body.

Notes

  • Pure refactor, no behavior change. Same four setters, same reset values, fired at the same point in the disconnect handler.
  • latencyMs remains intentionally excluded — it resets via the connectionStatus edge effect, which coordinates with its own connecting-edge ref.
  • The helper's deps are [] (the useState setters are stable), so its identity never changes; it's added to the disconnect effect's dep array.
  • The existing App.test.tsx disconnect test (asserts all four pieces reset) is unchanged and still passes — it exercises the behavior through the same disconnect event, so it covers the helper transparently.

Verification

npm run validate (1891 tests), npm run test:storybook (322) both pass.

🤖 Generated with Claude Code

Pull the four session-scoped UI resets (toolCallState / getPromptState /
readResourceState panels + optimistic currentLogLevel) out of the
disconnect listener into a colocated `resetSessionScopedUiState`
useCallback, so there's a single named place to extend as App.tsx accrues
more per-session state. The disconnect listener keeps its activeServerId +
modal-flag bookkeeping inline and calls the helper. Pure refactor — no
behavior change; the existing App.test.tsx disconnect test (asserts all
four pieces reset) is unchanged and still passes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cliffhall cliffhall added the v2 Issues and PRs for v2 label Jun 1, 2026
@cliffhall cliffhall merged commit 8b43755 into v2/main Jun 1, 2026
1 check passed
@cliffhall cliffhall deleted the refactor/1394-reset-session-state-helper branch June 1, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Issues and PRs for v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant